
import xml.etree.ElementTree as ET
if __name__ == '__main__':
    tree=ET.parse("python1.xml")#解析xml
    print("根元素：",tree.getroot().tag)#获得根节点名
    for x in tree.findall("student"):
        print(x.get("sex"))#属性
        print(x.find("name").text)#子节点，单
        print(x.find("age").text)
        print(x.find("qq").text)
        print(x.find("wechat").text)
        print(x.find("phone").text)
        print(x.find("degree").text)
        print("--"*15)